#!/bin/bash

function compileIPA() {
	curDate=$1
	mode=$2
	toolchainName=$3
	
	dir=~/Downloads/build/$curDate
	mkdir -p $dir
	echo 创建目录$dir

	# 修改项目名称即可给其他应用使用，需拷贝导出配置文件
	projectName=SwiftAppDemo
	workspaceName=${projectName}.xcworkspace
	archPath=$dir/${projectName}.xcarchive

	xcodebuild archive -workspace $workspaceName -scheme $projectName -configuration $mode -toolchain $toolchainName -archivePath $archPath -destination generic/platform=iOS
    xcodebuild -exportArchive -archivePath $archPath -exportPath $dir/${projectName}_AdHoc -exportOptionsPlist ExportOptions/exportOptionsAdHoc.plist -allowProvisioningUpdates
    # xcodebuild -exportArchive -archivePath $archPath -exportPath $dir/${projectName}_Dev -exportOptionsPlist ExportOptions/exportOptionsDev.plist
    # xcodebuild -exportArchive -archivePath $archPath -exportPath $dir/${projectName}_AppStore -exportOptionsPlist ExportOptions/exportOptionsAppStore.plist

}


date="`date +%Y%m%d_%H%M`"
compileIPA $date Release '360jiagubao.Swift'


